<settings-screen>
  <email-settings-warning function="'invite emails'"></email-settings-warning>
  <div class="row">
    <div class="col-md-4 col-md-offset-4 creation-container">
      <h3>New User</h3>
      <form class="form" name="$ctrl.userForm" ng-submit="saveUser()" novalidate>
        <div class="form-group required" ng-class="{ 'has-error':  ($ctrl.userForm.name | showError )}">
          <label class="control-label">Name</label>
          <input type="text" name="name" class="form-control" ng-model="user.name" ng-disabled="user.created" required/ autofocus>

          <error-messages input="$ctrl.userForm.name" form="$ctrl.userForm"></error-messages>
        </div>

        <div class="form-group required" ng-class="{ 'has-error': ($ctrl.userForm.email | showError ) }">
          <label class="control-label">Email</label>
          <input name="email" type="email" class="form-control" ng-model="user.email" ng-disabled="user.created" required/>

          <error-messages input="$ctrl.userForm.email" form="$ctrl.userForm"></error-messages>
        </div>

        <div class="form-group" ng-if="!user.created">
          <button class="btn btn-primary">Create user</button>
        </div>


        <div ng-if="user.created" class="alert alert-success alert-invited">
          <h4>The user has been created and should receive an invite email soon</h4>
          <p>You can use the following link to invite them yourself:</p>
          <textarea class="form-control m-t-10" rows="2" readonly>{{ inviteLink }}</textarea>
        </div>
      </form>
    </div>
  </div>
</settings-screen>
